Add decompress ratio check#52
Merged
Merged
Conversation
Adds two configuration knobs to `CompressionFilter` to control the maximum decompression ratio of deflate streams: - `maxDecompressRatio` (default 100): the maximum decompression ratio accepted by the filter. The ratio is computed cumulatively over the total bytes read and written, so an individual highly-compressed chunk does not on its own trip the check. - `decompressRatioMinSize` (default 1 MiB): a grace size below which the ratio check is skipped, avoiding false positives on small payloads where the initial chunks are highly-compressed. Given the growing number of `CompressionFilter` constructor parameters, it may be worth introducing a builder pattern, if the project agrees.
Member
Author
|
These knobs are loosely based on other deflators like
|
Contributor
|
Hi Piotr, sounds good. And +1 for the builder pattern. Thanks for the PR! |
Contributor
|
Hi @ppkarwasz, I have pushed the fluent API for the CompressionFilter class (94832ef), easing the injection of some of the parameters. Two things:
Just let me know if that seems correct from your side. I will backport it to 2.1.X and 2.0.X. Thanks! |
Contributor
|
Correction: the commit is f207407 |
Member
Author
|
LGTM, thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds two configuration knobs to
CompressionFilterto control the maximum decompression ratio of deflate streams:maxDecompressRatio(default 100): the maximum decompression ratio accepted by the filter. The ratio is computed cumulatively over the total bytes read and written, so an individual highly-compressed chunk does not on its own trip the check.decompressRatioMinSize(default 1 MiB): a grace size below which the ratio check is skipped, avoiding false positives on small payloads where the initial chunks are highly-compressed.Given the growing number of
CompressionFilterconstructor parameters, it may be worth introducing a builder pattern, if the project agrees.